package com.sth.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import tk.mybatis.spring.annotation.MapperScan;

import java.io.IOException;
import java.net.InetAddress;

@EnableDiscoveryClient
@SpringBootApplication
@MapperScan("com.sth.cloud.mapper")
@RefreshScope // 动态刷新
public class Main8002 {
    public static void main(String[] args) throws IOException {
        ConfigurableApplicationContext application = SpringApplication.run(Main8002.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String property = env.getProperty("server.servlet.context-path");
        String path = property == null ? "" : property;
        System.out.println(
                "\n\t" +
                        "----------------------------------------------------------\n\t" +
                        "Application Main8002 is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                        "External: \thttp://" + ip + ":" + port + path + "/\n\t" +
                        "Swagger3: " + "http://127.0.0.1:8002/swagger-ui/index.html" + "\n\t" +
                        "------------------------------------------------------------");
    }
}